package cn.plushine.service;

import cn.plushine.mapper.BaseUnitMapper;
import cn.plushine.pojo.Unit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BaseUnitServiceImpl implements BaseUnitService {

    @Autowired
    BaseUnitMapper baseUnitMapper;

    // 获取单位信息列表
    @Override
    public List<Unit> get(String input) {
        return baseUnitMapper.get(input);
    }

    // 删除单位信息
    @Override
    public int delete(int id) throws Exception {
        int deleteDB = baseUnitMapper.delete(id);
        if (deleteDB != 0) {
            return deleteDB;
        }
        throw new Exception("删除单位信息失败！");
    }

    // 修改品牌信息
    @Override
    public int save(Unit unit) throws Exception {
        int saveDB = baseUnitMapper.save(unit);
        if (saveDB != 0) {
            return saveDB;
        }
        throw new Exception("修改品牌信息失败！");
    }

    // 添加单位信息
    public int add(Unit unit) throws Exception {
        int addDB = baseUnitMapper.add(unit);
        if (addDB != 0) {
            return addDB;
        }
        throw new Exception("添加单位信息失败！");
    }

}
